// Base64 解码函数
let base64Decode = function(str) {
    let base64Chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/';
    let result = '';
    let padding = 0;

    for (let i = 0; i < str.length; i += 4) {
        let chunk =
            (base64Chars.indexOf(str.charAt(i)) << 18) |
            (base64Chars.indexOf(str.charAt(i + 1)) << 12) |
            (base64Chars.indexOf(str.charAt(i + 2)) << 6) |
            base64Chars.indexOf(str.charAt(i + 3));

        for (let j = 0; j < 3; j++) {
            if (i + j * 4 <= str.length - padding) {
                let byte = (chunk >> ((2 - j) * 8)) & 0xFF;
                result += String.fromCharCode(byte);
            } else {
                padding++;
            }
        }
    }

    return result;
}

// // 要解码的 Base64 编码字符串
let encodedStr = 'SGVsbG8sIFdvcmxkIQ==';
//
// // 进行 Base64 解码
let decodedStr = base64Decode(encodedStr);
//
console.log(decodedStr);
